#include <bits/stdc++.h>
using namespace std;

struct Node{
    int id;
    int d, v, a;
    int cslo;
};

Node car[100002];
int t, n, m, L, V, csy[100002], cnt[1000002], num[1000002];

bool quality_a() {
    for (int i = 1; i <= n; i++) {
        if (car[i].a != 0) {
            return 0;
        }
    }
    return 1;
}

bool quality_b() {
    for (int i = 1; i <= n; i++) {
        if (car[i].a <= 0) {
            return 0;
        }
    }
    return 1;
}

int main() {
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    scanf("%d", &t);
    while (t--) {
        scanf("%d %d %d %d", &n, &m, &L, &V);
        for (int i = 1; i <= n; i++) {
            scanf("%d %d %d", &car[i].d, &car[i].v, &car[i].a);
        }
        for (int i = 1; i <= m; i++) {
            scanf("%d", &csy[i]);
        }
        if (quality_a()) {
            int ans = 0;
            for (int i = 1; i <= n; i++) {
                if (car[i].v > V && car[i].d < csy[m]) {
                    ans++;
                }
            }
            if (ans == 0) {
                printf("0 %d\n", m);
            }
            else {
                printf("%d %d\n", ans, m - 1);
            }
            continue;
        }
        if (quality_b()) {
            for (int i = 1; i <= n; i++) {
                car[i].cslo = car[i].d + ceil((double)(V * V - car[i].v * car[i].v) / (double)(2 * car[i].a));
            }
            int ans = 0;
            for (int i = 1; i <= n; i++) {
                if (car[i].cslo < csy[m]) {
                    ans++;
                }
            }
            if (ans == 0) {
                printf("0 %d\n", m);
            }
            else {
                printf("%d %d\n", ans, m - 1);
            }
            continue;
        }
    }
    return 0;
}
